package elcs.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import elcs.member.model.MemberVO;
import elcs.point.model.TradePointService;
import elcs.test.model.QuestionService;

@Controller
public class TestController {
	@Resource(name="questionServiceImpl")
	private QuestionService questionService;
	@Resource(name="tradePointServiceImpl")
	private TradePointService tradePointService;
	
	@RequestMapping("/test/jointest.do")
	public ModelAndView joinTest(HttpSession session)
	{
		System.out.println("join Test");
		List list=questionService.joinTest();
		System.out.println(list);
		return new ModelAndView("join.test","list",list);
	}
	
	@RequestMapping("/test/jointestresult.do")
	public ModelAndView jointestResult(HttpSession session,String total)
	{
		System.out.println("jointestResult");
		int level=questionService.jointestResult(session,total);
		return new ModelAndView("redirect:/test/jointestresultview.do?level="+level);
	}
	
	@RequestMapping("/test/levelUpTest.do")
	public ModelAndView levelUpTest(HttpSession session)
	{
		System.out.println("LevelUp Test");
		MemberVO mvo=(MemberVO)session.getAttribute("mvo");
		List list=questionService.levelUpTest(mvo.getLevel()+1,session);
		int result=mvo.getLevel()+1;
		System.out.println("result "+result);
		System.out.println(session);
		tradePointService.minusPoint(session,""+result+" level Up Test");
		System.out.println(list);
		return new ModelAndView("level.test","list",list);
	}
	
	@RequestMapping("/test/leveltestresult.do")
	public ModelAndView leveltestresult(HttpSession session,String total)
	{
		System.out.println("jointestResult");
		boolean result=questionService.leveltestResult(session,total);
		return new ModelAndView("redirect:/test/leveltestresultview.do?result="+result);
	}
	
	@RequestMapping("/test/leveltestresultview.do")
	public ModelAndView leveltestResultView(HttpSession session,boolean result)
	{
		System.out.println("leveltestResultView");
		return new ModelAndView("levelresult.test","result",result);
	}
	
	
	
	
	@RequestMapping("/test/jointestresultview.do")
	public ModelAndView jointestResultView(HttpSession session,String level)
	{
		System.out.println("JointestResultView");
		return new ModelAndView("joinresult.test","level",level);
	}
	
	
	
	
	
	
	
	
	
	
	
}
